package com.anxinr.controller.shop;

import com.anxinr.pojo.base.QueryBase;
import com.anxinr.pojo.dto.ShopDTO;
import com.anxinr.pojo.entity.Shop;
import com.anxinr.result.Result;
import com.anxinr.service.ShopService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 门店模块
 * @author anxinr
 */
@CrossOrigin
@RestController
@RequestMapping("/shop")
@Api("门店模块")
@Slf4j
public class ShopController {
    @Autowired
    private ShopService shopService ;
    @ApiOperation("门店选择")
    @PostMapping("/getShops")
    public Result<PageInfo<List<ShopDTO>>> choiceShop(@RequestBody QueryBase<Shop> shop){
        return new Result(shopService.queryPageShop(shop)) ;
    }
    @ApiOperation("门店新增")
    @PostMapping("/save")
    public Result saveShop(@RequestBody ShopDTO shop){
        shopService.saveShop(shop);
        return Result.success() ;
    }
    @ApiOperation("门店修改")
    @PostMapping("/update")
    public Result updateShop(@RequestBody ShopDTO shop){
        shopService.updateShop(shop);
        return Result.success() ;
    }
    @ApiOperation("门店删除")
    @GetMapping("/delete")
    public Result deleteShop(@Param("id") Long id){
        shopService.deleteShop(id);
        return Result.success() ;
    }
}
